package com.travel.server.manager.impl.command.login;

import com.travel.common.CommonConstant;
import com.travel.common.util.VerifyCodeUtil;
import com.travel.server.manager.impl.command.AbstractCommand;
import com.travel.server.manager.dto.request.EmptyRequest;
import com.travel.server.manager.dto.response.login.RefreshVerifyCodeResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: LiZhenhui
 * @Date: 2018/10/26 15:59
 * @Desc:
 */
@Component
@Slf4j
public class RefreshVerifyCodeCommand extends AbstractCommand<EmptyRequest, RefreshVerifyCodeResponse> {
    @Override
    protected void checkInput(EmptyRequest request) {

    }

    @Override
    public RefreshVerifyCodeResponse handle(EmptyRequest request) {

        String[] codes = VerifyCodeUtil.genVerificatCode();

        setAttribute(CommonConstant.LOGIN_VERIFY_CODE, codes[0]);

        RefreshVerifyCodeResponse response = new RefreshVerifyCodeResponse();
        response.setPicBase64(codes[1]);
        return response;
    }
}
